layui.define(['layer', 'form', 'table', 'jquery', 'laydate'],
    function (exports) {
      var $ = layui.$,
          form = layui.form,
          layer = layui.layer,
          laydate = layui.laydate,
          table = layui.table;

      laydate.render({
        elem: '#createTime',
        range: true,//指定元素
        done: function (value, date, endDate) {
          $('input[name="createTimeBegin"]').val(date.year+"-"+date.month+"-"+date.date+" 00:00:00");
          $('input[name="createTimeEnd"]').val(endDate.year+"-"+endDate.month+"-"+endDate.date+" 23:59:59");
        }
      });

      $("#btn-query").click(function () {
        var formJsonData = $('.layui-form').serializeJSON();
        console.log(formJsonData)
        tableIns.reload({
          where: formJsonData
          , page: {
            curr: 1 //重新从第 1 页开始
          }
        });
      })

      //第一个实例
      var tableIns = table.render({
        id: 'authTableId',
        elem: '#table'
        , url: '/admin/vip/page' //数据接口
        , page: true //开启分页
        , cols: [[ //表头
          {field: 'authName', align: "center", title: '真实姓名', width: 350}
          , {field: 'mobile', align: "center", title: '手机号', width: 140}
          , {field: 'price', align: "center", title: '价格', width: 120}
          , {field: 'memberCategoryName', align: "center", title: '套餐类型', width: 120}
          , {field: 'createDate', align: "center", title: '购买时间', width: 240}
          , {field: 'expiryDate', align: "center", title: '到期时间', width: 180}
        ]],
        request: {
          pageName: 'page' //页码的参数名称，默认：page
          , limitName: 'size' //每页数据量的参数名，默认：limit
        }
      });

      exports('users_vip', {}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
    });